package com.easy.base.api.controller;

import com.easy.base.api.model.dto.ResultBody;
import com.easy.base.api.model.dto.ResultPager;
import com.easy.base.api.model.entity.MenuItemEntity;
import com.easy.base.api.service.IMenuInfoService;

import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(tags = { "menu" })
@RequestMapping("/api")
@RestController
public class MenuController extends BaseController<MenuItemEntity, IMenuInfoService> {

    @ApiOperation(nickname = "insertMenu", value = "新增菜单")
    @PostMapping(value = "menu", produces = MediaType.APPLICATION_JSON_VALUE)
    @Override
    public ResponseEntity<ResultBody<MenuItemEntity>> insertEntity(
            @RequestBody(required = true) MenuItemEntity entity) {
        return super.insertEntity(entity);
    }

    @ApiOperation(nickname = "insertMenu", value = "删除单个菜单")
    @DeleteMapping(value = "menu/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
    @Override
    public ResponseEntity<ResultBody<String>> removeEntity(@PathVariable(value = "id", required = true) String id) {
        return super.removeEntity(id);
    }

    @ApiOperation(nickname = "removeMenu", value = "删除多个菜单")
    @DeleteMapping(value = "menu", produces = MediaType.APPLICATION_JSON_VALUE)
    @Override
    public ResponseEntity<ResultBody<String>> removeEntity(@RequestBody(required = true) String[] ids) {
        return super.removeEntity(ids);
    }

    @ApiOperation(nickname = "selectMenus", value = "分页查询菜单")
    @GetMapping(value = "menu", produces = MediaType.APPLICATION_JSON_VALUE)
    @Override
    public ResponseEntity<ResultBody<ResultPager<MenuItemEntity>>> selectEntities(
            MenuItemEntity entity) {
        return super.selectEntities(entity);
    }

    @ApiOperation(nickname = "selectMenu", value = "查询菜单")
    @GetMapping(value = "menu/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
    @Override
    public ResponseEntity<ResultBody<MenuItemEntity>> selectEntity(
            @PathVariable(value = "id", required = true) String id) {
        return super.selectEntity(id);
    }

    @ApiOperation(nickname = "updateMenu", value = "更新菜单")
    @PutMapping(value = "menu/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
    @Override
    public ResponseEntity<ResultBody<MenuItemEntity>> updateEntity(
            @PathVariable(value = "id", required = true) String id,
            @RequestBody MenuItemEntity entity) {
        return super.updateEntity(id, entity);
    }

}
